﻿using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Localization;
using Morgma.Infographics.Models;

namespace GoogleAnalytics.Drivers {
	public class GoogleInfograhpicsSettingsPartDriver : ContentPartDriver<GoogleInfographicsSettingsPart> {
		public GoogleInfograhpicsSettingsPartDriver() {
			T = NullLocalizer.Instance;
		}
		public Localizer T { get; set; }
		protected override string Prefix { get { return "GoogleInfograhpicsSettings"; } }		
		//GET
		protected override DriverResult Editor(GoogleInfographicsSettingsPart part, dynamic shapeHelper) {
			return ContentShape("Parts_GoogleInfographicsSettings_Edit",
					() => shapeHelper.EditorTemplate(
						TemplateName: "Parts/GoogleInfographicsSettings",
						Model: part,
						Prefix: Prefix));
		}

		//POST
		protected override DriverResult Editor(GoogleInfographicsSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
			updater.TryUpdateModel(part, Prefix, null, null);
			return Editor(part, shapeHelper);
		}
	}
}